#![allow(dead_code)]

struct CopyLrn {}

impl CopyLrn {
    fn hello() {
        println!("Copy learnning")
    }
}

#[cfg(test)]
mod tests {
    // use super::*;

    #[test]
    /// NOTE: 类型组件都实现了copy，那么类型就可以copy，否则不
    /// NOTE: Clone is super trait of Copy
    /// `pub trait Copy: Clone { }`
    fn copy_test() {
        #[derive(Debug, Copy, Clone)]
        struct Foo;

        let x = Foo;
        let _y = x;

        println!("{:?}", x)
    }

    #[test]
    /// Copy实现
    fn impl_copy() {
        #[derive(Debug)]
        struct Foo;

        impl Copy for Foo {}

        impl Clone for Foo {
            fn clone(&self) -> Self {
                *self
            }
        }

        let x = Foo;
        let _y = x;

        println!("{:?}", x);
    }
}
